package com.smh.a20exerciseDemo7;

import java.util.ArrayList;
import java.util.Collections;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Test {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list, 10, 5, 10, 50, 100, 200, 500, 800, 2, 80, 300, 700);

        MyThread t = new MyThread(list);

        FutureTask<Integer> ft = new FutureTask<>(t);
        FutureTask<Integer> ft2 = new FutureTask<>(t);
        FutureTask<Integer> ft3 = new FutureTask<>(t);

        Thread thread = new Thread(ft, "抽奖箱1");
        Thread thread2 = new Thread(ft2, "抽奖箱2");
        Thread thread3 = new Thread(ft3, "抽奖箱3");

        thread.start();
        thread2.start();
        thread3.start();

        int result = ft.get();
        int result2 = ft2.get();
        int result3 = ft3.get();

        if (result > result2 && result > result3) {
            System.out.println("1");
        } else if (result2 > result && result2 > result3) {
            System.out.println("2");
        } else {
            System.out.println("3");
        }

    }
}
